<?php
$servername = "127.0.0.1";
$username = "web";
$password = "123456";
$dbname = "web2022_com";

// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);

// 检测连接
if ($conn->connect_error) {
    die("连接失败: " . $conn->connect_error);
}
echo "连接成功";
$sql = "select * from user";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
    // 输出数据
    while ($row = $result->fetch_assoc()) {
        var_dump($row);
    }
} else {
    echo "0 结果";
}
$conn->close();
